package think.thread.sychron.c02.toast;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

public class ToastMain {

	public static void main(String[] args) throws Exception{
		
		ToastQueue dryQueue = new ToastQueue(), butterQueue = new ToastQueue(), jamQueue = new ToastQueue();
		
		Toaster toaster=new Toaster(dryQueue);
		
		ToastButter butter=new ToastButter(dryQueue, butterQueue);
		
		ToastJam jam=new ToastJam(butterQueue, jamQueue);
		
		ExecutorService exec=Executors.newCachedThreadPool();
		
		exec.execute(toaster);
		exec.execute(butter);
		exec.execute(jam);
		
//		TimeUnit.SECONDS.sleep(3);
		TimeUnit.MILLISECONDS.sleep(3050);
		
		exec.shutdownNow();
	}

}
